package ZiDingYidemo;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        GirlFriend gf = new GirlFriend();
        while (true) {
            try {
                System.out.println("输入名字");
                String name = sc.nextLine();
                gf.setName(name);

                System.out.println("输入年龄");
                String ages = sc.nextLine();
                int age = Integer.parseInt(ages);
                gf.setAge(age);
                break;

            } catch (NumberFormatException e) {
                System.out.println("年龄格式");
                continue;
            } catch (NameFormatException e) {
                e.printStackTrace();
            } catch (AgeOutOfBoundsException e) {
                e.printStackTrace();
            }
        }
        System.out.println(gf);
    }
}